package controllers

import (
	"github.com/astaxie/beego"
	"yunshangxiaozhao/models"
)

type ManagerController struct {
	beego.Controller
}

func (m *ManagerController) RetData(resp map[string]interface{}) {
	resp["code"] = 200
	m.Data["json"] = resp
	m.ServeJSON()
}

// @Title QueryComments
// @Description 查看所有投诉/建议/意见(管理者权限)
// @Success 200 {object} query success
// @Failure 403 user not exist
// @router /comment [get]
func (u *UserController) QueryAllComments() {
	resp := make(map[string]interface{})
	userId := u.getUserIdFromSession()
	limit, page := u.getLimitAndPage()

	userComment, err := models.QueryAllCommentById(userId, page, limit)
	if err != nil {
		u.Abort("GetDataFail")
	}
	resp["data"] = userComment
	resp["msg"] = "获取所有用户投诉信息成功"

	u.RetData(resp)
}
